<?php


abstract class BaseCalendar extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $seq_id;


	
	protected $status_id;


	
	protected $user_id;


	
	protected $person_id;


	
	protected $user_roles;


	
	protected $is_personal = 0;


	
	protected $title;


	
	protected $geo_name_id;


	
	protected $point_latitude;


	
	protected $point_longitude;


	
	protected $address;


	
	protected $duration;


	
	protected $duration_metric;


	
	protected $times_to_repeat;


	
	protected $updated_at;


	
	protected $created_at;


	
	protected $start_at;


	
	protected $ends_at;

	
	protected $collCalendarI18ns;

	
	protected $lastCalendarI18nCriteria = null;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

  
  protected $culture;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getSeqId()
	{

		return $this->seq_id;
	}

	
	public function getStatusId()
	{

		return $this->status_id;
	}

	
	public function getUserId()
	{

		return $this->user_id;
	}

	
	public function getPersonId()
	{

		return $this->person_id;
	}

	
	public function getUserRoles()
	{

		return $this->user_roles;
	}

	
	public function getIsPersonal()
	{

		return $this->is_personal;
	}

	
	public function getTitle()
	{

		return $this->title;
	}

	
	public function getGeoNameId()
	{

		return $this->geo_name_id;
	}

	
	public function getPointLatitude()
	{

		return $this->point_latitude;
	}

	
	public function getPointLongitude()
	{

		return $this->point_longitude;
	}

	
	public function getAddress()
	{

		return $this->address;
	}

	
	public function getDuration()
	{

		return $this->duration;
	}

	
	public function getDurationMetric()
	{

		return $this->duration_metric;
	}

	
	public function getTimesToRepeat()
	{

		return $this->times_to_repeat;
	}

	
	public function getUpdatedAt($format = 'Y-m-d H:i:s')
	{

		if ($this->updated_at === null || $this->updated_at === '') {
			return null;
		} elseif (!is_int($this->updated_at)) {
						$ts = strtotime($this->updated_at);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [updated_at] as date/time value: " . var_export($this->updated_at, true));
			}
		} else {
			$ts = $this->updated_at;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getCreatedAt($format = 'Y-m-d H:i:s')
	{

		if ($this->created_at === null || $this->created_at === '') {
			return null;
		} elseif (!is_int($this->created_at)) {
						$ts = strtotime($this->created_at);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [created_at] as date/time value: " . var_export($this->created_at, true));
			}
		} else {
			$ts = $this->created_at;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getStartAt($format = 'Y-m-d H:i:s')
	{

		if ($this->start_at === null || $this->start_at === '') {
			return null;
		} elseif (!is_int($this->start_at)) {
						$ts = strtotime($this->start_at);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [start_at] as date/time value: " . var_export($this->start_at, true));
			}
		} else {
			$ts = $this->start_at;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getEndsAt($format = 'Y-m-d H:i:s')
	{

		if ($this->ends_at === null || $this->ends_at === '') {
			return null;
		} elseif (!is_int($this->ends_at)) {
						$ts = strtotime($this->ends_at);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [ends_at] as date/time value: " . var_export($this->ends_at, true));
			}
		} else {
			$ts = $this->ends_at;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function setId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = CalendarPeer::ID;
		}

	} 
	
	public function setSeqId($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->seq_id !== $v) {
			$this->seq_id = $v;
			$this->modifiedColumns[] = CalendarPeer::SEQ_ID;
		}

	} 
	
	public function setStatusId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->status_id !== $v) {
			$this->status_id = $v;
			$this->modifiedColumns[] = CalendarPeer::STATUS_ID;
		}

	} 
	
	public function setUserId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->user_id !== $v) {
			$this->user_id = $v;
			$this->modifiedColumns[] = CalendarPeer::USER_ID;
		}

	} 
	
	public function setPersonId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->person_id !== $v) {
			$this->person_id = $v;
			$this->modifiedColumns[] = CalendarPeer::PERSON_ID;
		}

	} 
	
	public function setUserRoles($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->user_roles !== $v) {
			$this->user_roles = $v;
			$this->modifiedColumns[] = CalendarPeer::USER_ROLES;
		}

	} 
	
	public function setIsPersonal($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->is_personal !== $v || $v === 0) {
			$this->is_personal = $v;
			$this->modifiedColumns[] = CalendarPeer::IS_PERSONAL;
		}

	} 
	
	public function setTitle($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->title !== $v) {
			$this->title = $v;
			$this->modifiedColumns[] = CalendarPeer::TITLE;
		}

	} 
	
	public function setGeoNameId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->geo_name_id !== $v) {
			$this->geo_name_id = $v;
			$this->modifiedColumns[] = CalendarPeer::GEO_NAME_ID;
		}

	} 
	
	public function setPointLatitude($v)
	{

		if ($this->point_latitude !== $v) {
			$this->point_latitude = $v;
			$this->modifiedColumns[] = CalendarPeer::POINT_LATITUDE;
		}

	} 
	
	public function setPointLongitude($v)
	{

		if ($this->point_longitude !== $v) {
			$this->point_longitude = $v;
			$this->modifiedColumns[] = CalendarPeer::POINT_LONGITUDE;
		}

	} 
	
	public function setAddress($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->address !== $v) {
			$this->address = $v;
			$this->modifiedColumns[] = CalendarPeer::ADDRESS;
		}

	} 
	
	public function setDuration($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->duration !== $v) {
			$this->duration = $v;
			$this->modifiedColumns[] = CalendarPeer::DURATION;
		}

	} 
	
	public function setDurationMetric($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->duration_metric !== $v) {
			$this->duration_metric = $v;
			$this->modifiedColumns[] = CalendarPeer::DURATION_METRIC;
		}

	} 
	
	public function setTimesToRepeat($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->times_to_repeat !== $v) {
			$this->times_to_repeat = $v;
			$this->modifiedColumns[] = CalendarPeer::TIMES_TO_REPEAT;
		}

	} 
	
	public function setUpdatedAt($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [updated_at] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->updated_at !== $ts) {
			$this->updated_at = $ts;
			$this->modifiedColumns[] = CalendarPeer::UPDATED_AT;
		}

	} 
	
	public function setCreatedAt($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [created_at] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->created_at !== $ts) {
			$this->created_at = $ts;
			$this->modifiedColumns[] = CalendarPeer::CREATED_AT;
		}

	} 
	
	public function setStartAt($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [start_at] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->start_at !== $ts) {
			$this->start_at = $ts;
			$this->modifiedColumns[] = CalendarPeer::START_AT;
		}

	} 
	
	public function setEndsAt($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [ends_at] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->ends_at !== $ts) {
			$this->ends_at = $ts;
			$this->modifiedColumns[] = CalendarPeer::ENDS_AT;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->seq_id = $rs->getString($startcol + 1);

			$this->status_id = $rs->getInt($startcol + 2);

			$this->user_id = $rs->getInt($startcol + 3);

			$this->person_id = $rs->getInt($startcol + 4);

			$this->user_roles = $rs->getString($startcol + 5);

			$this->is_personal = $rs->getInt($startcol + 6);

			$this->title = $rs->getString($startcol + 7);

			$this->geo_name_id = $rs->getInt($startcol + 8);

			$this->point_latitude = $rs->getFloat($startcol + 9);

			$this->point_longitude = $rs->getFloat($startcol + 10);

			$this->address = $rs->getString($startcol + 11);

			$this->duration = $rs->getInt($startcol + 12);

			$this->duration_metric = $rs->getString($startcol + 13);

			$this->times_to_repeat = $rs->getInt($startcol + 14);

			$this->updated_at = $rs->getTimestamp($startcol + 15, null);

			$this->created_at = $rs->getTimestamp($startcol + 16, null);

			$this->start_at = $rs->getTimestamp($startcol + 17, null);

			$this->ends_at = $rs->getTimestamp($startcol + 18, null);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 19; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Calendar object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(CalendarPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			CalendarPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
    if ($this->isModified() && !$this->isColumnModified(CalendarPeer::UPDATED_AT))
    {
      $this->setUpdatedAt(time());
    }

    if ($this->isNew() && !$this->isColumnModified(CalendarPeer::CREATED_AT))
    {
      $this->setCreatedAt(time());
    }

		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(CalendarPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = CalendarPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += CalendarPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			if ($this->collCalendarI18ns !== null) {
				foreach($this->collCalendarI18ns as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = CalendarPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}


				if ($this->collCalendarI18ns !== null) {
					foreach($this->collCalendarI18ns as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}


			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = CalendarPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getSeqId();
				break;
			case 2:
				return $this->getStatusId();
				break;
			case 3:
				return $this->getUserId();
				break;
			case 4:
				return $this->getPersonId();
				break;
			case 5:
				return $this->getUserRoles();
				break;
			case 6:
				return $this->getIsPersonal();
				break;
			case 7:
				return $this->getTitle();
				break;
			case 8:
				return $this->getGeoNameId();
				break;
			case 9:
				return $this->getPointLatitude();
				break;
			case 10:
				return $this->getPointLongitude();
				break;
			case 11:
				return $this->getAddress();
				break;
			case 12:
				return $this->getDuration();
				break;
			case 13:
				return $this->getDurationMetric();
				break;
			case 14:
				return $this->getTimesToRepeat();
				break;
			case 15:
				return $this->getUpdatedAt();
				break;
			case 16:
				return $this->getCreatedAt();
				break;
			case 17:
				return $this->getStartAt();
				break;
			case 18:
				return $this->getEndsAt();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = CalendarPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getSeqId(),
			$keys[2] => $this->getStatusId(),
			$keys[3] => $this->getUserId(),
			$keys[4] => $this->getPersonId(),
			$keys[5] => $this->getUserRoles(),
			$keys[6] => $this->getIsPersonal(),
			$keys[7] => $this->getTitle(),
			$keys[8] => $this->getGeoNameId(),
			$keys[9] => $this->getPointLatitude(),
			$keys[10] => $this->getPointLongitude(),
			$keys[11] => $this->getAddress(),
			$keys[12] => $this->getDuration(),
			$keys[13] => $this->getDurationMetric(),
			$keys[14] => $this->getTimesToRepeat(),
			$keys[15] => $this->getUpdatedAt(),
			$keys[16] => $this->getCreatedAt(),
			$keys[17] => $this->getStartAt(),
			$keys[18] => $this->getEndsAt(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = CalendarPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setSeqId($value);
				break;
			case 2:
				$this->setStatusId($value);
				break;
			case 3:
				$this->setUserId($value);
				break;
			case 4:
				$this->setPersonId($value);
				break;
			case 5:
				$this->setUserRoles($value);
				break;
			case 6:
				$this->setIsPersonal($value);
				break;
			case 7:
				$this->setTitle($value);
				break;
			case 8:
				$this->setGeoNameId($value);
				break;
			case 9:
				$this->setPointLatitude($value);
				break;
			case 10:
				$this->setPointLongitude($value);
				break;
			case 11:
				$this->setAddress($value);
				break;
			case 12:
				$this->setDuration($value);
				break;
			case 13:
				$this->setDurationMetric($value);
				break;
			case 14:
				$this->setTimesToRepeat($value);
				break;
			case 15:
				$this->setUpdatedAt($value);
				break;
			case 16:
				$this->setCreatedAt($value);
				break;
			case 17:
				$this->setStartAt($value);
				break;
			case 18:
				$this->setEndsAt($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = CalendarPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setSeqId($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setStatusId($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setUserId($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setPersonId($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setUserRoles($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setIsPersonal($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setTitle($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setGeoNameId($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setPointLatitude($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setPointLongitude($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setAddress($arr[$keys[11]]);
		if (array_key_exists($keys[12], $arr)) $this->setDuration($arr[$keys[12]]);
		if (array_key_exists($keys[13], $arr)) $this->setDurationMetric($arr[$keys[13]]);
		if (array_key_exists($keys[14], $arr)) $this->setTimesToRepeat($arr[$keys[14]]);
		if (array_key_exists($keys[15], $arr)) $this->setUpdatedAt($arr[$keys[15]]);
		if (array_key_exists($keys[16], $arr)) $this->setCreatedAt($arr[$keys[16]]);
		if (array_key_exists($keys[17], $arr)) $this->setStartAt($arr[$keys[17]]);
		if (array_key_exists($keys[18], $arr)) $this->setEndsAt($arr[$keys[18]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(CalendarPeer::DATABASE_NAME);

		if ($this->isColumnModified(CalendarPeer::ID)) $criteria->add(CalendarPeer::ID, $this->id);
		if ($this->isColumnModified(CalendarPeer::SEQ_ID)) $criteria->add(CalendarPeer::SEQ_ID, $this->seq_id);
		if ($this->isColumnModified(CalendarPeer::STATUS_ID)) $criteria->add(CalendarPeer::STATUS_ID, $this->status_id);
		if ($this->isColumnModified(CalendarPeer::USER_ID)) $criteria->add(CalendarPeer::USER_ID, $this->user_id);
		if ($this->isColumnModified(CalendarPeer::PERSON_ID)) $criteria->add(CalendarPeer::PERSON_ID, $this->person_id);
		if ($this->isColumnModified(CalendarPeer::USER_ROLES)) $criteria->add(CalendarPeer::USER_ROLES, $this->user_roles);
		if ($this->isColumnModified(CalendarPeer::IS_PERSONAL)) $criteria->add(CalendarPeer::IS_PERSONAL, $this->is_personal);
		if ($this->isColumnModified(CalendarPeer::TITLE)) $criteria->add(CalendarPeer::TITLE, $this->title);
		if ($this->isColumnModified(CalendarPeer::GEO_NAME_ID)) $criteria->add(CalendarPeer::GEO_NAME_ID, $this->geo_name_id);
		if ($this->isColumnModified(CalendarPeer::POINT_LATITUDE)) $criteria->add(CalendarPeer::POINT_LATITUDE, $this->point_latitude);
		if ($this->isColumnModified(CalendarPeer::POINT_LONGITUDE)) $criteria->add(CalendarPeer::POINT_LONGITUDE, $this->point_longitude);
		if ($this->isColumnModified(CalendarPeer::ADDRESS)) $criteria->add(CalendarPeer::ADDRESS, $this->address);
		if ($this->isColumnModified(CalendarPeer::DURATION)) $criteria->add(CalendarPeer::DURATION, $this->duration);
		if ($this->isColumnModified(CalendarPeer::DURATION_METRIC)) $criteria->add(CalendarPeer::DURATION_METRIC, $this->duration_metric);
		if ($this->isColumnModified(CalendarPeer::TIMES_TO_REPEAT)) $criteria->add(CalendarPeer::TIMES_TO_REPEAT, $this->times_to_repeat);
		if ($this->isColumnModified(CalendarPeer::UPDATED_AT)) $criteria->add(CalendarPeer::UPDATED_AT, $this->updated_at);
		if ($this->isColumnModified(CalendarPeer::CREATED_AT)) $criteria->add(CalendarPeer::CREATED_AT, $this->created_at);
		if ($this->isColumnModified(CalendarPeer::START_AT)) $criteria->add(CalendarPeer::START_AT, $this->start_at);
		if ($this->isColumnModified(CalendarPeer::ENDS_AT)) $criteria->add(CalendarPeer::ENDS_AT, $this->ends_at);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(CalendarPeer::DATABASE_NAME);

		$criteria->add(CalendarPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setSeqId($this->seq_id);

		$copyObj->setStatusId($this->status_id);

		$copyObj->setUserId($this->user_id);

		$copyObj->setPersonId($this->person_id);

		$copyObj->setUserRoles($this->user_roles);

		$copyObj->setIsPersonal($this->is_personal);

		$copyObj->setTitle($this->title);

		$copyObj->setGeoNameId($this->geo_name_id);

		$copyObj->setPointLatitude($this->point_latitude);

		$copyObj->setPointLongitude($this->point_longitude);

		$copyObj->setAddress($this->address);

		$copyObj->setDuration($this->duration);

		$copyObj->setDurationMetric($this->duration_metric);

		$copyObj->setTimesToRepeat($this->times_to_repeat);

		$copyObj->setUpdatedAt($this->updated_at);

		$copyObj->setCreatedAt($this->created_at);

		$copyObj->setStartAt($this->start_at);

		$copyObj->setEndsAt($this->ends_at);


		if ($deepCopy) {
									$copyObj->setNew(false);

			foreach($this->getCalendarI18ns() as $relObj) {
				$copyObj->addCalendarI18n($relObj->copy($deepCopy));
			}

		} 

		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new CalendarPeer();
		}
		return self::$peer;
	}

	
	public function initCalendarI18ns()
	{
		if ($this->collCalendarI18ns === null) {
			$this->collCalendarI18ns = array();
		}
	}

	
	public function getCalendarI18ns($criteria = null, $con = null)
	{
				include_once 'lib/model/om/BaseCalendarI18nPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collCalendarI18ns === null) {
			if ($this->isNew()) {
			   $this->collCalendarI18ns = array();
			} else {

				$criteria->add(CalendarI18nPeer::ID, $this->getId());

				CalendarI18nPeer::addSelectColumns($criteria);
				$this->collCalendarI18ns = CalendarI18nPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(CalendarI18nPeer::ID, $this->getId());

				CalendarI18nPeer::addSelectColumns($criteria);
				if (!isset($this->lastCalendarI18nCriteria) || !$this->lastCalendarI18nCriteria->equals($criteria)) {
					$this->collCalendarI18ns = CalendarI18nPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastCalendarI18nCriteria = $criteria;
		return $this->collCalendarI18ns;
	}

	
	public function countCalendarI18ns($criteria = null, $distinct = false, $con = null)
	{
				include_once 'lib/model/om/BaseCalendarI18nPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(CalendarI18nPeer::ID, $this->getId());

		return CalendarI18nPeer::doCount($criteria, $distinct, $con);
	}

	
	public function addCalendarI18n(CalendarI18n $l)
	{
		$this->collCalendarI18ns[] = $l;
		$l->setCalendar($this);
	}

  public function getCulture()
  {
    return $this->culture;
  }

  public function setCulture($culture)
  {
    $this->culture = $culture;
  }

  public function getName()
  {
    $obj = $this->getCurrentCalendarI18n();

    return ($obj ? $obj->getName() : null);
  }

  public function setName($value)
  {
    $this->getCurrentCalendarI18n()->setName($value);
  }

  public function getDescription()
  {
    $obj = $this->getCurrentCalendarI18n();

    return ($obj ? $obj->getDescription() : null);
  }

  public function setDescription($value)
  {
    $this->getCurrentCalendarI18n()->setDescription($value);
  }

  protected $current_i18n = array();

  public function getCurrentCalendarI18n()
  {
    if (!isset($this->current_i18n[$this->culture]))
    {
      $obj = CalendarI18nPeer::retrieveByPK($this->getId(), $this->culture);
      if ($obj)
      {
        $this->setCalendarI18nForCulture($obj, $this->culture);
      }
      else
      {
        $this->setCalendarI18nForCulture(new CalendarI18n(), $this->culture);
        $this->current_i18n[$this->culture]->setCulture($this->culture);
      }
    }

    return $this->current_i18n[$this->culture];
  }

  public function setCalendarI18nForCulture($object, $culture)
  {
    $this->current_i18n[$culture] = $object;
    $this->addCalendarI18n($object);
  }

} 